package com.ruicar.afs.cloud.batch.frame.control;


import com.ruicar.afs.cloud.batch.enums.MessageType;
import com.ruicar.afs.cloud.batch.frame.logger.WsMonitorHelper;
import lombok.extern.slf4j.Slf4j;

import java.text.MessageFormat;

@Slf4j(topic = "BATCH_CONTROL")
public abstract class BatchControlRunner extends Thread{
    private boolean finished = false;
    private boolean subFinished = false;
    private boolean selfFinished = false;
    private Throwable throwable;
    protected void setFinished(){
        this.finished = true;
    }
    protected void setThrowable(Throwable throwable){
        this.throwable = throwable;
    }
    public Throwable getThrowable(){
        return throwable;
    }
    public boolean isFinished(){
        return finished;
    }

    public boolean isSubFinished() {
        return subFinished;
    }

    public void setSubFinished(boolean subFinished) {
        this.subFinished = subFinished;
    }

    public boolean isSelfFinished() {
        return selfFinished;
    }

    public void setSelfFinished(boolean selfFinished) {
        this.selfFinished = selfFinished;
    }

    public void logRunInfo(){
        log.info("=================[{}]正在执行============",this.getName());
        WsMonitorHelper.sendMessage(MessageType.INFO,MessageFormat.format("================={0}正在执行============",this.getName()));
    }
}
